from django.shortcuts import render
from com.user.sign_in_controller import is_sign_in


def normal_index(request):
    data_set = {"user_name": None}
    return render(request, 'index.html', data_set)


def sign_in_index(request, user_name):
    data_set = {"user_name": user_name}
    return render(request, 'index.html', data_set)


class Index(object):
    def __init__(self, request):
        self.request = request

    def run(self):
        (sign_in, user_name) = is_sign_in(self.request)
        if not sign_in:
            return normal_index(self.request)
        return sign_in_index(self.request, user_name)
